(ns amjil.word
  (:require [clojure.core.match :refer [match]]
            [clojure.string :as str]))

(defn match-suffix
  [word]
  (match [(take-last 4 word)]
    [([\г \и \й \н] :seq)] (str (str/join "" (drop-last 4 word)) " " "ᠦᠨ")
    [([\с \а \а \р] :seq)] (str (str/join "" (drop-last 4 word)) "ᠰᠠᠭᠠᠷ")
    [([\г \а \а \н] :seq)] (str (str/join "" (drop-last 4 word)) "ᠭᠠᠨ")
    :else (match [(take-last 3 word)]
            [([\т \а \й] :seq)] (str (str/join "" (drop-last 3 word)) " " "ᠲᠠᠢ")
            [([\и \й \г] :seq)] (str (str/join "" (drop-last 3 word)) " " "ᠢ")
            [([\г \ү \й] :seq)] (str (str/join "" (drop-last 3 word)) " " "ᠭᠥᠢ")
            [([\с \а \н] :seq)] (str (str/join "" (drop-last 3 word)) " " "ᠭᠥᠢ")
            [([\д \о \г] :seq)] (str (str/join "" (drop-last 3 word)) "" "ᠳᠠᠭ")
            :else (match [(take-last 2 word)]
                    [([\л \д] :seq)] (str (str/join "" (drop-last 1 word)) " " "ᠳᠤ")
                    [([\е \д] :seq)] (str (str/join "" (drop-last 1 word)) " " "ᠳᠤ")
                    [([\г \т] :seq)] (str (str/join "" (drop-last 1 word)) " " "ᠲᠤ")
                    [([\э \н] :seq)] (str (str/join "" (drop-last 2 word)) " " "ᠨ")))))

(defn match-prefix
  [word]
  (match [(take 3 word)]
    [([\н \э \г] :seq)] (str "ᠨᠢᠭᠡ" (str/join "" (drop 3 word)))
    :else (match [(take 2 word)]
            [([\и \х] :seq)] (str "ᠶᠡᠬᠡ" (str/join "" (drop 2 word))))))


(defn first-vowel
  [word]
  (let [lower (str/lower-case word)]
    (if (some #{(first lower)} (list \а \э \и \о \у \ө \ү))
      (first lower)
      (second lower))))

(defn patch-vowel
  [word]
  ())

(def char-maps
  { \ф \ᠹ
    \ж \ᠵ})

(defn char-translate
  [char]
  (char-maps char))

(defn word-translate
  [word])
